-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ubisoft OAuth integration #56
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/bux42/tm-dojo/hswTALSAgqDCjsK4U98hrUcwHAwv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for the most part, just a few minor things 👍
const sessions = db.collection('sessions'); | ||
const sessionId = uuid(); | ||
await sessions.insertOne({ | ||
sessionId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not something we have to do right now, but I wonder if we should store the hash of the secret instead of the real session. Obviously that means we'd also have to change the validation when requests come in - let me know what you think.
Adds a "Login with Ubisoft" button to authenticate the user.
⚠ Requires .env changes! ⚠
OAuth requires you to create an application on api.trackmania.com:
Client:
NEXT_PUBLIC_CLIENT_ID=<CLIENT_ID from api.trackmania.com>
Server:
TM_API_CLIENT_ID=<CLIENT_ID from api.trackmania.com>
TM_API_CLIENT_SECRET=<CLIENT_SECRET from api.trackmania.com>
Flow Summary
api.trackmania.com/...
authentication URL<domain>/auth_redirect
containing a code and state in query params/authorize
endpoint{withCredentials: true}
config in axios (will create an axios interface with this default in a later PR)New Endpoints
/authorize
for first authentication/logout
to logout. Removes session and sends back a sessionId cookie with an age of -1 (instantly deletes cookie)/me
to fetch user information for the logged in user